﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.RenameUI {
    import flash.display.*;
    import Events.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.ext.*;
    import Display.aswingui.*;

    public class RenameDialogView extends GenericDialogView {

        public static const DIALOG_WIDTH:int = 744;
        public static const BODY_PAD_TOP:int = 10;
        public static const BODY_PAD_BOTTOM:int = 0;
        public static const BODY_PAD_SIDE:int = 20;

        protected var m_listData_city:VectorListModel;
        protected var m_listData_bus:VectorListModel;

        public function RenameDialogView(_arg1:Dictionary, _arg2:Array, _arg3:Array, _arg4:String="", _arg5:String="", _arg6:int=8, _arg7:Function=null, _arg8:String="", _arg9:int=0, _arg10:String="", _arg11:Function=null, _arg12:String=""){
            this.m_listData_city = new VectorListModel();
            this.m_listData_bus = new VectorListModel();
            this.refreshCityModel(_arg2);
            this.refreshBusinessModel(_arg3);
            super(_arg1, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11, _arg12);
        }
        override protected function makeBackground():void{
            super.makeBackground();
            this.setPreferredWidth(DIALOG_WIDTH);
            this.setMinimumWidth(DIALOG_WIDTH);
            this.setMaximumWidth(DIALOG_WIDTH);
        }
        override protected function createTextArea():JPanel{
            var _local1:JPanel = ASwingHelper.makeFlowJPanel(FlowLayout.CENTER);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            var _local3:JTextField = ASwingHelper.makeTextField(m_message, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 12, EmbeddedArt.darkBrownTextColor);
            _local2.setPreferredWidth((DIALOG_WIDTH - (2 * BODY_PAD_SIDE)));
            ASwingHelper.setEasyBorder(_local1, BODY_PAD_TOP, BODY_PAD_SIDE, BODY_PAD_BOTTOM, BODY_PAD_SIDE);
            var _local4:JPanel = this.createTopPanel();
            var _local5:AssetPane = this.createDivider();
            var _local6:JPanel = this.createBottomPanel();
            _local2.appendAll(_local4, ASwingHelper.verticalStrut(5), _local5, _local3, ASwingHelper.verticalStrut(5), _local6);
            _local1.append(_local2);
            return (_local1);
        }
        protected function createTopPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:GridList = new GridList(this.m_listData_city, new RenameCellFactory(RenameCell, m_assetDict), 1, 1);
            _local2.setTileWidth((DIALOG_WIDTH - (2 * BODY_PAD_SIDE)));
            _local2.setTileHeight(95);
            _local2.setPreferredHeight(95);
            _local2.setSelectable(false);
            _local2.addEventListener(RenameEvent.FINISH_CLICK, this.onRenameEvent);
            _local2.addEventListener(RenameEvent.PROPOSE_CLICK, this.onRenameEvent);
            _local2.addEventListener(RenameEvent.PURCHASE_CLICK, this.onRenameEvent);
            _local2.addEventListener(RenameEvent.REQUEST_CLICK, this.onRenameEvent);
            _local1.append(_local2);
            return (_local1);
        }
        protected function createDivider():AssetPane{
            var _local1:DisplayObject = (new (m_assetDict["dialog_div"])() as DisplayObject);
            _local1.width = (DIALOG_WIDTH - (2 * BODY_PAD_SIDE));
            var _local2:AssetPane = new AssetPane(_local1);
            return (_local2);
        }
        protected function createBottomPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:VerticalScrollingList = new VerticalScrollingList(m_assetDict, this.m_listData_bus, new RenameCellFactory(RenameCell, m_assetDict), 1, 3, (DIALOG_WIDTH - (2 * BODY_PAD_SIDE)), 300);
            _local1.append(_local2);
            return (_local1);
        }
        public function refreshCityModel(_arg1:Array):void{
            this.refreshModel(this.m_listData_city, _arg1);
        }
        public function refreshBusinessModel(_arg1:Array):void{
            this.refreshModel(this.m_listData_bus, _arg1);
        }
        protected function refreshModel(_arg1:VectorListModel, _arg2:Array):void{
            _arg1.clear();
            var _local3:int;
            while (_local3 < _arg2.length) {
                _arg1.append(_arg2[_local3]);
                _local3++;
            };
        }
        protected function onRenameEvent(_arg1:RenameEvent):void{
            _arg1.stopPropagation();
            _arg1.stopImmediatePropagation();
            this.dispatchEvent(new RenameEvent(_arg1.type, _arg1.itemName));
        }

    }
}//package Display.RenameUI 
